package com.lincoln.service;

import com.lincoln.entity.client.DbClient;
import com.lincoln.repository.TokenClientRepository;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.Map;

@Service
@Transactional(rollbackFor = Exception.class)
public class TokenClientService extends BaseService<DbClient, TokenClientRepository> {
    /**
     * 建立分页排序请求
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    public PageRequest buildPageRequest(int pageNo, int pageSize, Sort.Order... orders) {
        Sort sort = Sort.by(orders);
        return PageRequest.of(pageNo, pageSize, sort);
    }

    public Predicate createPredicate(Root<DbClient> root, CriteriaBuilder cb, Map<String, Object> params) {
        Predicate result = cb.and();
        return result;
    }
}
